//
//  MyViewModel.m
//  HQJFacilitator
//
//  Created by mymac on 16/9/21.
//  Copyright © 2016年 Fujian first time iot technology investment co., LTD. All rights reserved.
//

#import "MyViewModel.h"
#import "PersonalInformationViewController.h"
#import "BonusOperationViewController.h"
#import "LoginViewController.h"
#import "QrCodeViewController.h"
#import "SetViewController.h"
#import "AuditViewController.h"

@implementation MyViewModel
-(void)myRequst:(void(^)())myBlock {
//    NSString *str = [FileEngine filePathNameReadName:@"memberid" andstye:fileLoginStyle];
    NSString *myUrl = [NSString stringWithFormat:@"%@myInfor/memberid/%@",AppOrg_URL,MmberidStr];

        if (MmberidStr) {
            [RequestEngine HQJFacilitatorRequestDetailsUrl:myUrl complete:^(NSDictionary *dic) {
                NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:dic[@"result"][@"realname"],@"realname",dic[@"result"][@"mobile"],@"mobile",dic[@"result"][@"bonus"],@"bonus", nil];
                [Manager sharedManager].bonus = [NSString stringWithFormat:@"%@",dic[@"result"][@"bonus"]];

                [FileEngine filePathNameCreateandNameMutablefilePatch:fileDefaultStyle Dictionary:dic1];
//                myBlock();
            } andError:^(NSError *error) {
                
            } ShowHUD:YES];
            
            NSString * urlStr1 = [NSString stringWithFormat:@"%@myTrade/memberid/%@",AppOrg_URL,MmberidStr];
            [RequestEngine HQJFacilitatorRequestDetailsUrl:urlStr1 complete:^(NSDictionary *dic) {
//                HQJLog(@"首页请求的第二个:%@",dic);
                
                NSString *dicStr = dic[@"result"][@"bonus"];
                
                NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:dicStr,@"bonus",nil];
                [FileEngine filePathNameCreateandNameMutablefilePatch:fileHomeDataStyle Dictionary:dic1];
                    NSLog(@"￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥￥:\n%@",[FileEngine filePathNameReadName:@"bonus" andstye:fileHomeDataStyle]);
 
                myBlock();
            } andError:^(NSError *error) {
                
            } ShowHUD:YES];
        }

    
    
//    }
}



-(void)ClickCellIndexPath:(NSIndexPath *)index andViewController:(UIViewController *)viewController andTit:(NSString *)title {
    
    
    
    
        if (index.section == 0) {
            if (index.row == 0) {
                PersonalInformationViewController *PIVC = [[PersonalInformationViewController alloc]init];
                PIVC.title = title;
                [viewController.navigationController pushViewController:PIVC animated:YES];
            } else  {
                BonusOperationViewController *BOVC = [[BonusOperationViewController alloc]init];
                BOVC.title = title;
                [viewController.navigationController pushViewController:BOVC animated:YES];
                
                
            }
        }else if (index.section == 1) {
           

            if (index.row == 0) {
                QrCodeViewController *QCVC = [[QrCodeViewController alloc]init];
                QCVC.title = title;
                [viewController.navigationController pushViewController:QCVC animated:YES];
            } else {
                AuditViewController *AVC = [[AuditViewController alloc]init];
                AVC.title = title;
                [viewController.navigationController pushViewController:AVC animated:YES];
            }
            
        } else {
            
            SetViewController *setVC = [[SetViewController alloc]init];
            setVC.title = title;
            [viewController.navigationController pushViewController:setVC animated:YES];
        }

   
    
    
    
}



@end
